package com.czh.seckill.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;

@Configuration
public class RabbitMQConfigTopic {
//    public static final String QUEUE01 = "queue_topic01";
//    public static final String QUEUE02 = "queue_topic02";
//    public static final String EXCHANGE_TOPIC = "exchange_topic";
//    public static final String ROUTING_KEY_TOPIC01 = "#.queue.#";
//    public static final String ROUTING_KEY_TOPIC02 = "*.queue.#";

//    @Bean
//    public Queue queue01() {
//        return new Queue(QUEUE01);
//    }
//
//    @Bean
//    public Queue queue02() {
//        return new Queue(QUEUE02);
//    }
//
//    @Bean
//    public TopicExchange topicExchange() {
//        return new TopicExchange(EXCHANGE_TOPIC);
//    }
//
//    @Bean
//    public Binding binding01() {
//        return BindingBuilder.bind(queue01()).to(topicExchange()).with(ROUTING_KEY_TOPIC01);
//    }
//
//    @Bean
//    public Binding binding02() {
//        return BindingBuilder.bind(queue02()).to(topicExchange()).with(ROUTING_KEY_TOPIC02);    }


    private static final String queue = "seckillQueue";
    private static final String exchange = "seckillExchange";

    @Bean
    public Queue seckillQueue() {
        return new Queue(queue, true);
    }

    @Bean
    public TopicExchange seckillExchange() {
        return new TopicExchange(exchange);
    }

    @Bean
    public Binding seckillBinding() {
        return BindingBuilder.bind(seckillQueue()).to(seckillExchange()).with("seckill.#");
    }




}
